home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-12-19 | 60.3 KB | 1,854 lines |
- Newsgroups: comp.sources.unix
- From: clyde@emx.utexas.edu (Clyde Hoover)
- Subject: v25i074: npasswd - replacement for passwd(1), Part01/03
- Sender: sources-moderator@pa.dec.com
- Approved: vixie@pa.dec.com
-
- Submitted-By: clyde@emx.utexas.edu (Clyde Hoover)
- Posting-Number: Volume 25, Issue 74
- Archive-Name: npasswd/part01
-
- Npasswd is a pretty-much-plug-compatable replacement for passwd(1). This
- version incorporates a password checking system that disallows simple-minded
- passwords.
-
- It does exactly ONE thing - change login passwords, though it would not be
- too difficult to make it do shells and GECOS stuff also.
-
- I have modeled npasswd after passwd(1) from 4.3BSD and SunOS 4.0, but it
- does not impliment the options those versions have. I have also included
- support for Sys VR3 password aging.
-
- This version runs at our site under SunOS 4.X, Ultrix 4.0, UMAX 4.3 and
- MORE/BSD.
-
- It is also available via anonymous FTP from emx.utexas.edu in the directory
- pub/npasswd.
-
- clyde@emx.utexas.edu
- -Clyde Hoover
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 3)."
- # Contents: MANIFEST README checkpasswd/Makefile
- # checkpasswd/call_ckpasswd.c checkpasswd/checkpasswd.3
- # checkpasswd/checkpasswd.c checkpasswd/checkpasswd.cf
- # checkpasswd/checkpasswd.h checkpasswd/dict/Makefile
- # checkpasswd/dict/README checkpasswd/dict/makedict.8
- # checkpasswd/dict/makedict.c checkpasswd/dict/viewdict.8
- # checkpasswd/dict/viewdict.c checkpasswd/libmain.c
- # checkpasswd/main.c checkpasswd/pwck_local.c
- # checkpasswd/pwck_passwd.c checkpasswd/version.h npasswd.1
- # npasswd.conf npasswd.help npasswd.motd npasswd.shar version.h
- # Wrapped by clyde@tigger.cc.utexas.edu on Fri Jan 25 10:35:05 1991
- for f in checkpasswd checkpasswd/dict; do
- mkdir $f
- done
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'MANIFEST' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MANIFEST'\"
- else
- echo shar: Extracting \"'MANIFEST'\" \(1213 characters\)
- sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
- XMANIFEST This file
- XREADME Do so
- XCHANGE.LOG Change descriptions from SCCS files
- XMakefile.dist q.e.d.
- Xversion.h Version information
- Xnpasswd.c Main program
- Xnpasswd.help Help file
- Xnpasswd.conf Sample config file (same as checkpasswd.cf)
- Xnpasswd.motd Sample message file
- Xpw_passwd.c Standard password file updater
- Xpw_yp.c Yellow Pages (NIS) updater
- Xpw_userinfo.c UTCC 'userinfo' updater
- Xnpasswd.1 Manual page boilerplate
- X
- Xcheckpasswd/README Readme file for password checker
- Xcheckpasswd/Makefile Makefile for password checker
- Xcheckpasswd/checkpasswd.8 Man page for password checker
- Xcheckpasswd/checkpasswd.3 Man page for library version
- Xcheckpasswd/checkpasswd.h Include file
- Xcheckpasswd/checkpasswd.cf Sample configuration file
- Xcheckpasswd/checkpasswd.c Driver for password checker
- Xcheckpasswd/libmain.c Library glue main
- Xcheckpasswd/main.c Standalone program main
- Xcheckpasswd/pwck_dict.c
- Xcheckpasswd/pwck_lexical.c
- Xcheckpasswd/pwck_local.c
- Xcheckpasswd/pwck_passwd.c
- Xcheckpasswd/util.c
- Xcheckpasswd/version.h
- Xcheckpasswd/call_ckpasswd.c
- X
- Xcheckpasswd/dict/README
- Xcheckpasswd/dict/Makefile
- Xcheckpasswd/dict/makedict.8
- Xcheckpasswd/dict/makedict.c
- Xcheckpasswd/dict/viewdict.8
- Xcheckpasswd/dict/viewdict.c
- END_OF_FILE
- if test 1213 -ne `wc -c <'MANIFEST'`; then
- echo shar: \"'MANIFEST'\" unpacked with wrong size!
- fi
- # end of 'MANIFEST'
- fi
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(4825 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XREADME for npasswd March 1990
- X
- X@(#)README 1.6 3/19/90 (cc.utexas.edu)
- X
- X* Introduction
- X
- XNpasswd is a pretty-much-plug-compatable replacement for passwd(1).
- XThis version incorporates a password checking system
- Xthat disallows simple-minded passwords.
- X
- XIt does exactly ONE thing - change login passwords, though it would
- Xnot be too difficult to make it do shells and GECOS stuff also.
- X
- XI have modeled npasswd after passwd(1) from 4.3BSD and SunOS 4.0, but
- Xit does not impliment the options those versions have.
- XI have also included support for Sys VR3 password aging, but I don't have
- Xa SysV box around to test it on.
- X
- X* About npasswd
- X
- XThe program is divided into upper and lower sections.
- XThe upper (driver) half deals with abstract data such as login names and
- Xpasswords. It has no knowledge of how or where passwords are stored.
- X
- XThe lower (method) half does data lookup and replacement. There are
- Xtwo different method modules provided with this distribution.
- X
- X pw_passwd.c - deals with standard /etc/passwd type files and
- X the hashed passwd database used in 4.3BSD.
- X pw_yp.c - deals with standard /etc/passwd files and Yellow Pages
- X passwd service.
- X
- XThe lower half hides all its data from the upper half, and vice versa.
- XThe upper and lower halves communicate via this interface:
- X
- X pw_initalize() Do initializations
- X pw_getuserbyname() Get user information by name
- X pw_permission() Check if user has permission
- X to change this users' password
- X pw_compare() Compare passwords (returns 1 on match, 0 if not)
- X pw_check() Check password (returns 1 if ok, 0 otherwise)
- X pw_replace() Replace the password
- X pw_cleanup() Cleanup
- X
- XBoth the upper and lower halves keep private state, and must determine
- Xsuch things as who invoked the program seperately.
- X
- XThis approach allows there to be one user interface for a variety of
- Xpassword storage methods. To support another method, such as shadow
- Xpassword files, a new collection of method routines need be written and
- Xlinked to npasswd.o.
- X
- XI have tried to minimalize the assumptions about what is available in the
- XC library and localized UNIX version dependancies.
- X
- X* Building npasswd
- X
- X- You will probably want to edit the manual page - it is fairly rough.
- X
- X- Look at the sources before you install to see if the assumptions
- X I made are correct for your site.
- X
- X1. Choose which version of npasswd you want to be the default and
- X retarget 'all' in Makefile to point to it.
- X
- X2. Read checkpasswd/README and configure Makefiles accordingly.
- X
- X3. Set the system target information in Makefile.
- X * For running under SunOS 4.X system, set OPTIONS = -DSUNOS4
- X * If you are thinking about running Sun "Secure RPC", add
- X -DSECURE_RPC to OPTIONS
- X * For running under System V, set OPTIONS = -DSYSV
- X * To use syslog(3), include -DSYSLOG in OPTIONS
- X * To update the 4.3BSD hashed password database,
- X include '-DBSD4_3' in OPTIONS.
- X * Change the lines for 'CF' and 'HF' to retarget the config and
- X or help files.
- X
- X4. Edit 'npasswd.help' to reflect the preferences chosen for the
- X password checking plus add any other local administrativa.
- X
- X5. Edit 'npasswd.conf' to reflect your preferences. See
- X checkpasswd/checkpasswd.8 (or the section below) for information about
- X the password checking configuration file.
- X
- X6. Do a 'make'.
- X
- X7. Become super-user and do 'make install'.
- X
- X8. If you built npasswd with -DSYSLOG, modify /etc/syslog.conf to log
- X messages for facility LOG_AUTH level LOG_INFO. This gives you a record
- X of password changes.
- X
- X* The configuration file explained
- X
- Xdictionary /path/to/dictionary [description]
- X /usr/dict/words is always looked in.
- X There are 2 good reasons to have a DBM version of each dictionary:
- X 1. Faster password checking.
- X 2. More secure checking. If there are no DBM files, then egrep(1)
- X is used and unfortunately, the candidate password must be put on the
- X command line - which makes it suspectible to being seen with ps(1).
- X
- X# singlecase yes | [no] - Pass single-case passwords
- X Allow single case passwords. Default is not to.
- X
- X# minlength N [5] - Minimum password length
- X 5 characters is the default minimum password length
- X
- X# maxlength N [8] Maximum effective password length
- X All this does is issue a warning message that just the first N
- X characters of a password are used.
- X
- X# printonly yes | [no] - Allow only printable characters
- X Allow non-printable (ASCII control) characters in passwords
- X
- X# badchars "<string>" - Replace illegal character list
- X Set a list of characters verboten in passwords.
- X This form REPLACES the built-in illegal character list.
- X Control characters may be specified by the '^X' convention.
- X
- X# badchars +"<string>" - Add to illegal character list
- X Adds to the built-in illegal character list.
- X
- X----------------------
- XBug reports & enhancements to
- Xclyde@emx.utexas.edu
- X
- X
- X -Clyde Hoover
- X
- END_OF_FILE
- if test 4825 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'checkpasswd/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/Makefile'\"
- else
- echo shar: Extracting \"'checkpasswd/Makefile'\" \(2971 characters\)
- sed "s/^X//" >'checkpasswd/Makefile' <<'END_OF_FILE'
- X
- X# -------------------------------------------------------------------- #
- X# #
- X# Author: Clyde Hoover #
- X# Computation Center #
- X# The University of Texas at Austin #
- X# Austin, Texas 78712 #
- X# clyde@emx.utexas.edu #
- X# uunet!cs.utexas.edu!ut-emx!clyde #
- X# #
- X#This code may be distributed freely, provided this notice is retained. #
- X# #
- X# -------------------------------------------------------------------- #
- X#
- X# Makefile for checkpasswd (application & library)
- X#
- X# @(#)Makefile 1.2 10/30/89 (cc.utexas.edu)
- X#
- XBINDIR = /usr/local
- XADMDIR = /usr/adm
- XDIR = .
- X
- XAPPNAME = checkpasswd
- XLIBNAME = checkpasswd.a
- X
- XDEBUG = -g -DDEBUG
- X# Set the following two lines to $(DEBUG) for debugging
- XCFLAGS = -O
- XLDFLAGS =
- XSUBDIRS = dict
- X
- X# If building with NDBM, use these lines
- XZLIB =
- XDBM = -DNDBM
- X
- XSOURCES = checkpasswd.h checkpasswd.c main.c pwck_dict.c pwck_passwd.c \
- X pwck_lexical.c pwck_local.c util.c checkpasswd.h
- X
- XOBJECTS = checkpasswd.o pwck_dict.o pwck_passwd.o pwck_lexical.o \
- X pwck_local.o util.o
- X
- XAPPMAIN = main.o
- XLIBMAIN = libmain.o
- X
- Xall: $(APPNAME) $(LIBNAME) dict
- X
- X$(APPNAME): $(APPMAIN) $(OBJECTS)
- X cc -o $(APPNAME) $(LDFLAGS) main.o $(OBJECTS)
- X
- X$(LIBNAME): $(LIBMAIN) $(OBJECTS)
- X -rm -f $(LIBNAME)
- X ar cr $(LIBNAME) $(LIBMAIN) $(OBJECTS)
- X ranlib $(LIBNAME)
- X
- X#
- X# If not using NDBM from libc, link in $(ZLIB) here
- X#
- Xpwck_dict.o: pwck_dict.c checkpasswd.h $(ZLIB)
- X $(CC) $(CFLAGS) $(DBM) -c pwck_dict.c
- X -@if [ -n "$(ZLIB)" ]; then\
- X set -x;\
- X $(LD) -r $*.o -o $*.x $(ZLIB);\
- X mv $*.x $*.o;\
- X fi
- X @echo Build programs in subdir \'dict\' with \"$(DBM)\"
- X
- X#
- X# Local library linked to this module to simplify rest of make procedure
- X# (UTEXAS CC only).
- X#
- XUILIB = /usr/local/lib/libuserinfo.a
- Xpwck_passwd.o: pwck_passwd.c checkpasswd.h
- X -@if [ -f $(UILIB) ]; then \
- X set -ex;\
- X $(CC) $(CFLAGS) -DUTEXAS_CC -c $<;\
- X $(LD) -r $*.o -o $*.x $(UILIB);\
- X mv $*.x $*.o;\
- X else \
- X set -x; $(CC) $(CFLAGS) -c $<;\
- X fi
- X
- Xclean::
- X rm -f *.o a.out checkpasswd core $(LIBNAME)
- X -@for f in $(SUBDIRS); do \
- X (cd $$f; make clean); done
- X
- Xdict::
- X (cd dict; make $(MFLAGS))
- X
- Xinstall: checkpasswd
- X install -s checkpasswd $(BINDIR)
- X install -c -m 0644 checkpasswd.cf $(ADMDIR)
- X
- X# ------------------------------------------------------------------
- X#
- X# Source dependancies
- X#
- Xcheckpasswd.o: checkpasswd.c checkpasswd.h
- Xmain.o: main.c checkpasswd.h version.h
- Xlibmain.o: libmain.c checkpasswd.h
- Xpwck_lexical.o: pwck_lexical.c checkpasswd.h
- Xpwck_local.o: pwck_local.c checkpasswd.h
- Xutil.o: util.c checkpasswd.h
- END_OF_FILE
- if test 2971 -ne `wc -c <'checkpasswd/Makefile'`; then
- echo shar: \"'checkpasswd/Makefile'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/Makefile'
- fi
- if test -f 'checkpasswd/call_ckpasswd.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/call_ckpasswd.c'\"
- else
- echo shar: Extracting \"'checkpasswd/call_ckpasswd.c'\" \(2518 characters\)
- sed "s/^X//" >'checkpasswd/call_ckpasswd.c' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * Code which calls the standalone password check program
- X */
- X#include <sys/types.h>
- X#include <sys/wait.h>
- X
- X#ifndef CHECKPASSWD
- X#define CHECKPASSWD "/usr/local/lib/checkpasswd"
- X#endif
- X/*
- X * checkpasswd - call password checker
- X *
- X * Returns: 0 if password can not be used
- X * 1 if password can be used
- X * -1 if error
- X */
- Xcheckpasswd(uid, newpw)
- Xint uid; /* User id wanting new password */
- Xchar *newpw; /* Password wanted */
- X{
- X int pid, /* Child pid */
- X i, /* Temp */
- X ii, /* Temp */
- X fds[2]; /* Pipe */
- X union wait status; /* Child return status */
- X char pwbuf[128]; /* Password temp buffer */
- X
- X#ifdef DEBUG
- X printf("checkpasswd %s\n", newpw);
- X#endif
- X (void) sprintf(pwbuf, "%s\n", newpw);
- X if (pipe(fds) < 0) {
- X perror("password_ok pipe");
- X return(-1);
- X }
- X if ((pid = fork()) == 0) {
- X (void) close(0);
- X (void) dup2(fds[0], 0); /* stdin from pipe */
- X (void) close(fds[0]);
- X (void) close(1);
- X (void) dup2(fds[1], 1); /* stdin to pipe */
- X (void) close(fds[1]);
- X (void) setgid(getgid()); /* NO-OP if not su */
- X (void) setuid(uid); /* NO-OP if not su */
- X (void) execl(CHECKPASSWD, "checkpasswd", "-o", 0);
- X exit(-1);
- X }
- X if (pid < 0) {
- X perror("checkpasswd fork");
- X return(-1);
- X }
- X i = write(fds[1], pwbuf, strlen(pwbuf));
- X (void) close(fds[1]);
- X (void) sleep(1);
- X bzero(pwbuf, sizeof(pwbuf));
- X ii = read(fds[0], pwbuf, sizeof(pwbuf));
- X (void) close(fds[0]);
- X while (wait(&status) != pid);
- X if (status.w_retcode == 255 || i <= 0 || ii < 0) {
- X fprintf(stderr, "Checkpasswd error\n");
- X return(-1);
- X }
- X if (status.w_retcode) {
- X printf("%s\n", pwbuf);
- X return(0);
- X }
- X return(1);
- X}
- END_OF_FILE
- if test 2518 -ne `wc -c <'checkpasswd/call_ckpasswd.c'`; then
- echo shar: \"'checkpasswd/call_ckpasswd.c'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/call_ckpasswd.c'
- fi
- if test -f 'checkpasswd/checkpasswd.3' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/checkpasswd.3'\"
- else
- echo shar: Extracting \"'checkpasswd/checkpasswd.3'\" \(1730 characters\)
- sed "s/^X//" >'checkpasswd/checkpasswd.3' <<'END_OF_FILE'
- X'\"
- X'\" @(#)checkpasswd.3 1.1 5/18/89 (cc.utexas.edu)
- X'\"
- X.TH CHECKPASSWD 3
- X.SH NAME
- Xcheckpasswd \- check password
- X.br
- Xsetcheckpasswd \- set parameters for checkpasswd
- X.SH SYNOPSIS
- X.B int checkpasswd(uid,\ password);
- X.br
- X.B int\ uid;
- X.br
- X.B char\ *password;
- X.sp
- X.B void setcheckpasswd(opt1,\ opt2,\ ...\ optn,\ 0);
- X.br
- X.B char\ *opt1,\ *opt2,\ ...\ *optn;
- X.SH DESCRIPTION
- X.I Checkpasswd
- Xchecks if
- X.B password
- Xis suitable for use by the UNIX user with user id
- X.BR uid .
- X.PP
- X.I Checkpasswd
- Xreturns 1 if the password is deemed suitable, and 0 otherwise.
- XAn informative message is also printed to the standard output
- Xif the password does not pass the tests.
- X.PP
- X.I Setcheckpasswd
- Xmay be used to change the operation parameters of
- X.IR checkpasswd .
- XIt accepts a list of strings which may be the following:
- X.TP
- X.B \-\^c
- XTake the next argument as the configuration file to read.
- XSee the CONFIGURATION section in
- X.IR checkpasswd (8)
- Xfor information on the configuration file.
- X.TP
- X.B \-\^e
- XReturn the detailed check status instead of 1 or 0.
- XSee below for an explanation.
- X.TP
- X.B \-\^s
- XSuppress message output.
- X.PP
- XThe detailed check status is one of the following:
- X.nf
- X-1 Password check did not complete.
- X0 Password passed all checks.
- X1 Password was a null string.
- X2 Password was \'too easy\' to guess.
- X3 Password was part of the users \'\fIfinger\fP\' information.
- X4 Password was found in a dictionary search.
- X5 Password contained an illegal character or sequence of characters.
- X6 Password was too short.
- X.fi
- X.SH SEE ALSO
- Xmakedict(8), viewdict(8), checkpasswd(8), npasswd(1)
- X.SH AUTHOR
- XClyde Hoover
- X.br
- XComputation Center
- X.br
- XThe University of Texas at Austin
- X.br
- XAustin, Texas
- X.br
- Xclyde@emx.utexas.edu, uunet!cs.utexas.edu!ut-emx!clyde
- END_OF_FILE
- if test 1730 -ne `wc -c <'checkpasswd/checkpasswd.3'`; then
- echo shar: \"'checkpasswd/checkpasswd.3'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/checkpasswd.3'
- fi
- if test -f 'checkpasswd/checkpasswd.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/checkpasswd.c'\"
- else
- echo shar: Extracting \"'checkpasswd/checkpasswd.c'\" \(3670 characters\)
- sed "s/^X//" >'checkpasswd/checkpasswd.c' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * checkpasswd.c - Password check driver and data initialization
- X */
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)checkpasswd.c 1.1 5/18/89 (cc.utexas.edu)";
- X#endif
- X
- X#include "checkpasswd.h"
- X
- X/*
- X * Table of password check parameters
- X * May be modified via the configuration file
- X */
- Xint single_case = 0, /* Single-case pwds ok */
- X print_only = 0, /* Printable ASCII chars only */
- X run_length = 3, /* How long chars runs can be */
- X min_length = 5, /* Minimum length */
- X max_length = 8; /* Maximum effective length */
- X
- X/*
- X * Control characters best avoided - commonly-used terminal controls.
- X * Add characters here or replace entire contents via the
- X * configuration file.
- X */
- X#define ctrl(d) ('d' & 037)
- X
- Xchar illegalcc[sizeof_illegalcc] = {
- X ctrl(c), /* Interrupt character */
- X ctrl(d), /* UNIX end-of-file */
- X ctrl(h), /* Backspace */
- X/* ctrl(i), */
- X ctrl(j), /* Newline */
- X ctrl(m), /* Carriage return */
- X ctrl(o), /* Flush output */
- X ctrl(r), /* Retype pending input */
- X ctrl(s), /* Suspend output */
- X ctrl(q), /* Resume output */
- X ctrl(y), /* Suspend program deferred */
- X ctrl(z), /* Suspend program immediate */
- X ctrl(\\), /* Quit signal */
- X ctrl([), /* escape - may do strange things to ttys if echoed */
- X ctrl(]), /* UNIX telnet escape */
- X '\0177', /* rubout */
- X 0
- X};
- X
- X/*
- X * The 'pwck_*' routines all use the PWCK_* return
- X * codes, which are then propigated up to the caller of checkpassword().
- X *
- X * All pwck_* routines in the table below are called thusly:
- X * pwck_*(password, userid, mesg)
- X * password = plaintext password string to test.
- X * userid = the user id which wants to use <password>.
- X * mesg = buffer to place long explanation into
- X *
- X * If more checks are desired, add the functions to the tables below.
- X */
- Xextern int
- X pwck_lexical(),
- X pwck_local(),
- X pwck_passwd(),
- X pwck_dictionary();
- X
- Xtypedef int (*function)();
- X
- Xfunction checkprocs[] = {
- X pwck_lexical,
- X pwck_local,
- X pwck_passwd,
- X pwck_dictionary,
- X 0
- X};
- X
- X/*
- X * checkpassword - Password candidate sanity checker.
- X *
- X * Arguments;
- X * password = plain text password string to check.
- X * userid = the uid whom the password is for, -1 to disable.
- X *
- X * Returns:
- X * PWCK_* values (see checkpasswd.h)
- X */
- Xcheckpassword(password, userid, mesg)
- Xchar *password; /* Plaintext of password to check */
- Xint userid; /* The user this is for */
- Xchar *mesg; /* Where to stash explanation message */
- X{
- X int rcode; /* General purpose scratch */
- X function *checkfunc; /* Check function pointer */
- X
- X if (password == 0 || *password == 0)
- X return(PWCK_NULL); /* Null password */
- X
- X mesg[0] = 0;
- X for (checkfunc = checkprocs; *checkfunc; checkfunc++) {
- X if ((rcode = (*checkfunc)(password, userid, mesg)) != PWCK_OK)
- X return(rcode);
- X }
- X return(PWCK_OK);
- X}
- X/* End checkpasswd.c */
- END_OF_FILE
- if test 3670 -ne `wc -c <'checkpasswd/checkpasswd.c'`; then
- echo shar: \"'checkpasswd/checkpasswd.c'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/checkpasswd.c'
- fi
- if test -f 'checkpasswd/checkpasswd.cf' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/checkpasswd.cf'\"
- else
- echo shar: Extracting \"'checkpasswd/checkpasswd.cf'\" \(626 characters\)
- sed "s/^X//" >'checkpasswd/checkpasswd.cf' <<'END_OF_FILE'
- X#
- X# checkpasswd configuration file
- X#
- X# @(#)checkpasswd.cf 1.1 5/18/89 (cc.utexas.edu)
- X#
- X# dictionary - Specify dictionary to look in.
- X# There may be multiple such entries.
- X# dictionary /path/to/dictionary [description]
- Xdictionary sysdict
- X
- X# singlecase yes | [no] - Pass single-case passwords
- X# singlecase yes
- X
- X# minlength N [5] - Minimum password length
- X# minlength 6
- X
- X# maxlength N [8] Maximum effective password length
- X# (for warning purposes only)
- X
- X# printonly yes | [no] - Allow only printable characters
- X
- X# badchars "<string>" - Replace illegal character list
- X# badchars +"<string>" - Add to illegal character list
- END_OF_FILE
- if test 626 -ne `wc -c <'checkpasswd/checkpasswd.cf'`; then
- echo shar: \"'checkpasswd/checkpasswd.cf'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/checkpasswd.cf'
- fi
- if test -f 'checkpasswd/checkpasswd.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/checkpasswd.h'\"
- else
- echo shar: Extracting \"'checkpasswd/checkpasswd.h'\" \(3267 characters\)
- sed "s/^X//" >'checkpasswd/checkpasswd.h' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * checkpasswd.h - Master include for checkpasswd
- X *
- X * @(#)checkpasswd.h 1.4 11/26/90 (cc.utexas.edu) /tmp_mnt/usr/share/src/private/ut/share/bin/passwd/checkpasswd/SCCS/s.checkpasswd.h
- X */
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X#ifdef SYSV
- X#include <string.h>
- X#define index strchr
- X#else
- X#include <strings.h>
- X#endif
- X
- X/*
- X * Return codes from checkpasswd() and pwck_*
- X * Also used as exit codes from main()
- X */
- X#define PWCK_FAIL -1 /* Failure during check process */
- X#define PWCK_OK 0 /* Password is ok to use */
- X#define PWCK_NULL 1 /* Password is the null string */
- X#define PWCK_OBVIOUS 2 /* Password is 'too obvious' */
- X#define PWCK_FINGER 3 /* Password is part of users finger info */
- X#define PWCK_INDICT 4 /* Password found in a dictionary */
- X#define PWCK_ILLCHAR 5 /* Illegal character in password */
- X#define PWCK_SHORT 6 /* Password too short */
- X
- X/*
- X * Dictionary info
- X */
- Xtypedef struct _dict {
- X char *dict_path, /* Path to dictionary */
- X *dict_desc; /* Descriptive phrase */
- X struct _dict *dict_next; /* Link to next dict */
- X} dictionary;
- Xextern dictionary *dictionaries; /* List of dictionaries to check */
- X
- X/*
- X * This is the default dicitonary to look in
- X * If you have some DBM dictionaries, either repoint this
- X * define or comment it out and place dictionaries in
- X * the configuration file.
- X */
- X#define DEFAULT_DICT "/usr/dict/words" /* Default dictionary */
- X
- X#ifndef CONFIG_FILE
- X /* Set configuration file name */
- X# ifdef DEBUG
- X# define CONFIG_FILE "checkpasswd.cf"
- X# else
- X# define CONFIG_FILE "/usr/adm/checkpasswd.cf"
- X# endif /* DEBUG */
- X#endif /* CONFIG_FILE */
- X
- X/*
- X * Password preferences
- X */
- Xint single_case, /* Single-case passwords ok or not */
- X print_only, /* Printable characters only */
- X run_length, /* Maximum length of character runs */
- X min_length, /* Minimum password length */
- X max_length; /* Maximum effective length */
- X
- X#define sizeof_illegalcc 128
- Xextern char illegalcc[]; /* Control characters not allowed */
- X
- X/*
- X * Misc inline subroutine macros
- X */
- X
- X/* Single string comparasion */
- X#define try(P,C,V) { \
- X if (_cistrcmp((P),(C)) == 0) \
- X return(V); \
- X }
- X
- X/* Multiple string comparasion */
- X#define mtry(P,C,V) { \
- X int i; \
- X if ((i = _instring((P),(C),(V))) != PWCK_OK) \
- X return(i); \
- X}
- X
- X/* Compact string compare */
- X#define streq(X,S) (_cistrncmp((X),(S), strlen(X)) == 0)
- X
- X
- X/* End checkpasswd.h */
- END_OF_FILE
- if test 3267 -ne `wc -c <'checkpasswd/checkpasswd.h'`; then
- echo shar: \"'checkpasswd/checkpasswd.h'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/checkpasswd.h'
- fi
- if test -f 'checkpasswd/dict/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/dict/Makefile'\"
- else
- echo shar: Extracting \"'checkpasswd/dict/Makefile'\" \(1552 characters\)
- sed "s/^X//" >'checkpasswd/dict/Makefile' <<'END_OF_FILE'
- X
- X# -------------------------------------------------------------------- #
- X# #
- X# Author: Clyde Hoover #
- X# Computation Center #
- X# The University of Texas at Austin #
- X# Austin, Texas 78712 #
- X# clyde@emx.utexas.edu #
- X# uunet!cs.utexas.edu!ut-emx!clyde #
- X# #
- X#This code may be distributed freely, provided this notice is retained. #
- X# #
- X# -------------------------------------------------------------------- #
- X#
- X# Makefile for checkpasswd auxillary programs
- X#
- X# @(#)Makefile 1.1 5/18/89 (cc.utexas.edu)
- X#
- XDEBUG = -g -DDEBUG
- X# Change the line below to $(DEBUG)
- XCFLAGS = -O
- X
- X# If building with MDBM, use these lines
- X#ZLIB = ../mdbm/libmdbm.a
- X#ZFLAGS = -DMDBM -I../mdbm $(ZLIB)
- X
- X# If building with NDBM, use these lines
- XZLIB =
- XZFLAGS = -DNDBM
- X
- X
- Xall: makedict viewdict
- X
- Xinstall::
- X @echo No installation to be done
- X
- Xmakedict: makedict.c $(ZLIB)
- X $(CC) $(CFLAGS) -o makedict makedict.c $(ZFLAGS)
- X
- Xviewdict: viewdict.c $(ZLIB)
- X $(CC) $(CFLAGS) -o viewdict viewdict.c $(ZFLAGS)
- X
- Xclean::
- X -rm -f *.o a.out core makedict viewdict
- X
- X../mdbm/libmdbm.a::
- X (cd ../mdbm; make $(MFLAGS))
- END_OF_FILE
- if test 1552 -ne `wc -c <'checkpasswd/dict/Makefile'`; then
- echo shar: \"'checkpasswd/dict/Makefile'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/dict/Makefile'
- fi
- if test -f 'checkpasswd/dict/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/dict/README'\"
- else
- echo shar: Extracting \"'checkpasswd/dict/README'\" \(320 characters\)
- sed "s/^X//" >'checkpasswd/dict/README' <<'END_OF_FILE'
- XREADME for checkpasswd dictionary programs 4/25/89
- X
- XThe programs 'makedict' and 'viewdict' may be build to use either the
- X4.3BSD 'ndbm' routines or the 'mdbm' routines provided in ../mdbm
- X
- XEdit the Makefile to choose which option. This option must match that
- Xchosen for 'view_dict.o' in ../Makefile (for checkpasswd).
- X
- END_OF_FILE
- if test 320 -ne `wc -c <'checkpasswd/dict/README'`; then
- echo shar: \"'checkpasswd/dict/README'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/dict/README'
- fi
- if test -f 'checkpasswd/dict/makedict.8' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/dict/makedict.8'\"
- else
- echo shar: Extracting \"'checkpasswd/dict/makedict.8'\" \(384 characters\)
- sed "s/^X//" >'checkpasswd/dict/makedict.8' <<'END_OF_FILE'
- X'\"
- X'\" @(#)makedict.8 1.1 5/18/89 (cc.utexas.edu)
- X'\"
- X.TH MAKEDICT 1
- X.SH NAME
- Xmakedict \- Build DBM dictionary
- X.SH SYNOPSIS
- X.B makedict
- Xdbm_dictionary
- X.SH DESCRIPTION
- X.I Makedict
- Xreads the standard input and builds a DBM dictionary data base for use by
- X.IR checkpasswd (8).
- XIf
- X.I dbm_dictionary
- Xdoes not exist, it is created, else the data read is added to it.
- X.SH SEE ALSO
- Xviewdict
- END_OF_FILE
- if test 384 -ne `wc -c <'checkpasswd/dict/makedict.8'`; then
- echo shar: \"'checkpasswd/dict/makedict.8'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/dict/makedict.8'
- fi
- if test -f 'checkpasswd/dict/makedict.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/dict/makedict.c'\"
- else
- echo shar: Extracting \"'checkpasswd/dict/makedict.c'\" \(2606 characters\)
- sed "s/^X//" >'checkpasswd/dict/makedict.c' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * makedict - Make DBM version of password dictionary
- X */
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)makedict.c 1.2 10/4/89 (cc.utexas.edu) /usr/src/ut/bin/passwd/checkpasswd/dict/SCCS/s.makedict.c";
- X#endif
- X
- X#ifdef MDBM
- X#include "mdbm.h"
- X#define DBM struct mdbm
- X#define DBM_CLOSE mdbm_close
- X#endif
- X
- X#ifdef NDBM
- X#include <ndbm.h>
- X#define DBM_CLOSE dbm_close
- X#endif
- X
- X
- X/*
- X * What cpp needs is a way for the programmer to issue an error
- X * message here and abort compilation
- X */
- X#if !defined(MDBM) && !defined(NDBM)
- X "Either NDBM or MDBM must be defined"
- X#endif
- X
- X#include <sys/file.h>
- X#include <stdio.h>
- X
- Xchar line[80]; /* Input buffer */
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X DBM *dp; /* Database pointer */
- X int recs = 0; /* Record counter */
- X datum d, /* Data datum */
- X k; /* Key datum */
- X#ifdef SYSV
- X#define index strchr
- X#endif
- X char *index();
- X
- X if (argc < 2) {
- X printf("Usage: makedict dbm-file < input\n");
- X exit(1);
- X }
- X#ifdef NDBM
- X dp = dbm_open(argv[1], O_RDWR, 0);
- X if (dp == 0) {
- X if ((dp = dbm_open(argv[1], O_RDWR|O_CREAT, 0644)) == 0) {
- X perror(argv[1]);
- X exit(1);
- X }
- X }
- X#endif
- X#ifdef MDBM
- X dp = mdbm_open(argv[1], O_RDWR, (int *)0, (int *)0, (char *)0);
- X if (dp == 0) {
- X if ((dp = mdbm_open(argv[1], O_RDWR|O_CREAT, 0644,
- X (int *)0, (int *)0, (char *)0)) == 0) {
- X perror(argv[1]);
- X exit(1);
- X }
- X }
- X#endif
- X while (!feof(stdin)) {
- X char *p;
- X
- X (void) fgets(line, sizeof(line), stdin);
- X if (p = index(line, '\n'))
- X *p = 0;
- X d.dptr = line;
- X d.dsize = strlen(line);
- X#ifdef MDBM
- X mdbm_store(dp, d, d, 1);
- X#endif
- X#ifdef NDBM
- X dbm_store(dp, d, d, DBM_INSERT);
- X#endif
- X recs++;
- X }
- X DBM_CLOSE(dp);
- X printf("%s built, %d records\n", argv[1], recs);
- X}
- END_OF_FILE
- if test 2606 -ne `wc -c <'checkpasswd/dict/makedict.c'`; then
- echo shar: \"'checkpasswd/dict/makedict.c'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/dict/makedict.c'
- fi
- if test -f 'checkpasswd/dict/viewdict.8' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/dict/viewdict.8'\"
- else
- echo shar: Extracting \"'checkpasswd/dict/viewdict.8'\" \(350 characters\)
- sed "s/^X//" >'checkpasswd/dict/viewdict.8' <<'END_OF_FILE'
- X'\"
- X'\" @(#)viewdict.8 1.1 5/18/89 (cc.utexas.edu) /home/emx/u2/cc/clyde/src/new/passwd/checkpasswd/dict/SCCS/s.viewdict.8
- X'\"
- X.TH VIEWDICT 1
- X.SH NAME
- Xviewdict \- View DBM dictionary
- X.SH SYNOPSIS
- X.B viewdict
- Xdbm_dictionary
- X.SH DESCRIPTION
- X.I Viewdict
- Xreads a dictionary data base and prints its contents to the standard
- Xoutput.
- X.SH SEE ALSO
- Xmakedict
- END_OF_FILE
- if test 350 -ne `wc -c <'checkpasswd/dict/viewdict.8'`; then
- echo shar: \"'checkpasswd/dict/viewdict.8'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/dict/viewdict.8'
- fi
- if test -f 'checkpasswd/dict/viewdict.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/dict/viewdict.c'\"
- else
- echo shar: Extracting \"'checkpasswd/dict/viewdict.c'\" \(2070 characters\)
- sed "s/^X//" >'checkpasswd/dict/viewdict.c' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * viewdict - view DBM dictionary data base
- X */
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)viewdict.c 1.1 5/18/89 (cc.utexas.edu) /home/emx/u2/cc/clyde/src/new/passwd/checkpasswd/dict/SCCS/s.viewdict.c";
- X#endif
- X
- X#ifdef MDBM
- X#include "mdbm.h"
- X#define DBM struct mdbm
- X#endif
- X
- X#ifdef NDBM
- X#include <ndbm.h>
- X#endif
- X
- X#if !defined(MDBM) && !defined(NDBM)
- X "Either NDBM or MDBM must be defined"
- X#endif
- X
- X#include <sys/file.h>
- X#include <stdio.h>
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X DBM *dp; /* Database pointer */
- X datum k; /* Key datum */
- X char t[128]; /* Output buffer */
- X
- X if (argc < 2) {
- X printf("Usage: viewdict dbm-dictionary\n");
- X exit(1);
- X }
- X#ifdef NDBM
- X dp = dbm_open(argv[1], O_RDWR, 0);
- X#endif
- X#ifdef MDBM
- X dp = mdbm_open(argv[1], O_RDONLY, 0, (int *)0, (int *)0, (char *)0);
- X#endif
- X if (dp == 0) {
- X perror(argv[1]);
- X exit(1);
- X }
- X/* printf("Dictionary %s\n", argv[1]); */
- X#ifdef NDBM
- X for (k = dbm_firstkey(dp); k.dptr != 0; k = dbm_nextkey(dp)) {
- X#endif
- X#ifdef MDBM
- X for (k = mdbm_firstkey(dp); k.dptr != 0; k = mdbm_nextkey(dp, k)) {
- X#endif
- X (void) strncpy(t, k.dptr, k.dsize);
- X t[k.dsize] = 0;
- X printf("%s\n", t);
- X }
- X exit(0);
- X}
- END_OF_FILE
- if test 2070 -ne `wc -c <'checkpasswd/dict/viewdict.c'`; then
- echo shar: \"'checkpasswd/dict/viewdict.c'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/dict/viewdict.c'
- fi
- if test -f 'checkpasswd/libmain.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/libmain.c'\"
- else
- echo shar: Extracting \"'checkpasswd/libmain.c'\" \(3482 characters\)
- sed "s/^X//" >'checkpasswd/libmain.c' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * checkpasswd - Library version main routine
- X *
- X * Compilation: ld -r -o checkpasswd.o checkpasswd.o libmain.o
- X * pwck_dict.o pwck_passwd.o pwck_lexical.o pwck_local.o util.o
- X */
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)libmain.c 1.2 11/14/89 (cc.utexas.edu)";
- X#endif
- X
- X#include "checkpasswd.h"
- X#include <varargs.h>
- X
- Xstatic char *replies[] = {
- X 0, /* PWCK_OK */
- X "Empty password", /* PWCK_NULL */
- X "This password is too easy to guess", /* PWCK_OBVIOUS */
- X "This password is part of your 'finger' information", /* PWCK_FINGER */
- X "This password was found in a dictionary", /* PWCK_INDICT */
- X "This password has an illegal character in it", /* PWCK_ILLCHAR */
- X "This password is too short", /* PWCK_SHORT */
- X 0
- X};
- X#define NREPLIES 7 /* Number of messages in replies */
- X
- Xstatic char elucidate[BUFSIZ]; /* Expanded error message */
- Xstatic char *configfile = CONFIG_FILE; /* Configuration file */
- Xstatic char configured = 0; /* Has cf been read? */
- Xstatic int silent = 0; /* Don't print messages */
- X returncode = 0; /* Return PWCK return code */
- Xint standalone = 0; /* Not a standalone application */
- X
- X/*
- X * setcheckpasswd - set parameters for checkpasswd
- X *
- X * e.g setcheckpasswd("-c", <configfile>, "-e", "-s", 0);
- X */
- Xsetcheckpasswd(va_alist)
- Xva_dcl /* List of options */
- X{
- X va_list optlist;
- X char *optx;
- X
- X va_start(optlist);
- X while (optx = va_arg(optlist, char *)) {
- X if (*optx == '-') {
- X switch(*++optx) {
- X case 's': /* -s (silent) */
- X silent = 1;
- X break;
- X case 'e': /* -e (return error code) */
- X returncode = 1;
- X break;
- X case 'c': /* -c config-file */
- X if (*++optx)
- X configfile = optx;
- X else {
- X optx = va_arg(optlist, char *);
- X if (optx)
- X configfile = optx;
- X }
- X break;
- X }
- X }
- X }
- X va_end(optlist);
- X}
- X
- X/*
- X * checkpasswd - check password candidate
- X *
- X * Returns 1 if <pwd> is ok to use as a password
- X * 0 if not & an appropriate error message is issued
- X */
- Xcheckpasswd(uid, pwd)
- Xint uid; /* User who wants this password */
- Xchar *pwd; /* Password they want */
- X{
- X int rc; /* Return code */
- X
- X#ifdef DEBUG
- X printf("checkpasswd %d %s\n", uid, pwd);
- X#endif
- X if (!configured) {
- X readconfig(configfile);
- X configured++;
- X }
- X rc = checkpassword(pwd, uid, elucidate);
- X if (rc == PWCK_OK) /* Always silent on success */
- X return(returncode ? rc : 1);
- X if (silent)
- X return(returncode ? rc : 0);
- X if (rc <= NREPLIES) {
- X if (elucidate[0])
- X printf("%s.\n", elucidate);
- X else if (replies[rc])
- X printf("%s.\n", replies[rc]);
- X else
- X putchar('\n');
- X }
- X return(returncode ? rc : 0);
- X}
- X/* End libmain.c */
- END_OF_FILE
- if test 3482 -ne `wc -c <'checkpasswd/libmain.c'`; then
- echo shar: \"'checkpasswd/libmain.c'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/libmain.c'
- fi
- if test -f 'checkpasswd/main.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/main.c'\"
- else
- echo shar: Extracting \"'checkpasswd/main.c'\" \(3839 characters\)
- sed "s/^X//" >'checkpasswd/main.c' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * checkpasswd - Main program for standalone version
- X * libmain.c is the driver for the library version
- X *
- X * Compilation: cc -o checkpasswd checkpasswd.c main.c pwck_dict.c
- X * pwck_passwd.c pwck_lexical.c pwck_local.c util.c
- X */
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)main.c 1.2 11/14/89 (cc.utexas.edu) /usr/src/ut/bin/passwd/checkpasswd/SCCS/s.main.c";
- X#endif
- X
- X#include "checkpasswd.h"
- X#include "version.h"
- X
- Xchar *replies[] = {
- X "This password is ok for use", /* PWCK_OK */
- X "Empty password", /* PWCK_NULL */
- X "This password is too easy to guess", /* PWCK_OBVIOUS */
- X "This password is part of your 'finger' information", /* PWCK_FINGER */
- X "This password was found in a dictionary", /* PWCK_INDICT */
- X "This password has an illegal character in it", /* PWCK_ILLCHAR */
- X "This password is too short", /* PWCK_SHORT */
- X 0
- X};
- X#define NREPLIES 7 /* Number of messages in replies */
- X
- Xchar elucidate[BUFSIZ]; /* Expanded error message */
- X
- Xint silent = 0, /* Silent mode switch */
- X oneshot = 0, /* Check only one password switch */
- X errornum = 0; /* Print error number with message */
- Xint standalone = 1; /* Running as standalone application */
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar **argv;
- X{
- X int uid = getuid(), /* Invoker's uid */
- X opt, /* Argument parser */
- X interactive = 0; /* In interactive mode? */
- X char *configfile = CONFIG_FILE; /* Configuration file */
- X extern char *optarg; /* From getopt() */
- X
- X /* Process argument list */
- X while ((opt = getopt(argc, argv, "c:eosu:V?")) != EOF) {
- X switch (opt) {
- X case 'c': /* -c config-file */
- X configfile = optarg;
- X break;
- X case 'e': /* -e [print status number] */
- X errornum++;
- X break;
- X case 'o': /* -o [check one password & quit] */
- X oneshot++;
- X break;
- X case 's': /* -s [silent mode] */
- X silent++;
- X break;
- X case 'u': /* -u [user id] */
- X if (uid == 0 && isdigit(*optarg))
- X uid = atoi(optarg);
- X break;
- X case 'V': /* -V [print version information] */
- X printf("Version %s\nPatch level %s\n",
- X version, patchlevel);
- X break;
- X case '?':
- X printf("Usage: checkpasswd [-c config] [-e] [-o] [-s] [-V] [-u uid]\n");
- X exit(0);
- X }
- X }
- X (void) readconfig(configfile);
- X interactive = isatty(fileno(stdin));
- X for (;;) {
- X int rc; /* Return code from checkpasswd() */
- X char ibuf[BUFSIZ]; /* Input buffer */
- X char *nl; /* Newline postition */
- X
- X if (interactive) {
- X printf("Password to check: ");
- X fflush(stdout);
- X }
- X if (fgets(ibuf, sizeof(ibuf), stdin) == NULL)
- X break;
- X if (nl = index(ibuf, '\n'))
- X *nl = 0;
- X if (ibuf[0] == 0)
- X continue;
- X rc = checkpassword(ibuf, uid, elucidate);
- X if (!silent) {
- X if (errornum)
- X printf("%d ", rc);
- X if (rc <= NREPLIES) {
- X if (elucidate[0])
- X printf("%s.\n", elucidate);
- X else if (replies[rc])
- X printf("%s.\n", replies[rc]);
- X else
- X putchar('\n');
- X }
- X else
- X printf("Error %d\n", rc);
- X }
- X if (oneshot)
- X exit(rc);
- X }
- X exit(0);
- X}
- X/* End main.c */
- END_OF_FILE
- if test 3839 -ne `wc -c <'checkpasswd/main.c'`; then
- echo shar: \"'checkpasswd/main.c'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/main.c'
- fi
- if test -f 'checkpasswd/pwck_local.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/pwck_local.c'\"
- else
- echo shar: Extracting \"'checkpasswd/pwck_local.c'\" \(1637 characters\)
- sed "s/^X//" >'checkpasswd/pwck_local.c' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * pwck_local - Perform 'local' password checks.
- X *
- X * Returns:
- X * PWCK_OBVIOUS if <password> == hostname
- X * PWCK_OK if otherwise
- X */
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)pwck_local.c 1.1 5/18/89 (cc.utexas.edu)";
- X#endif
- X
- X#include "checkpasswd.h"
- X
- Xpwck_local(password, userid, mesg)
- Xchar *password; /* Password to check */
- Xint userid; /* NOTUSED */
- Xchar *mesg; /* Message buffer */
- X{
- X char myname[32]; /* Scratch */
- X
- X (void) gethostname(myname, sizeof(myname));
- X try(password, myname, PWCK_OBVIOUS);
- X /*
- X * Could try full canoncalized hostname here in case gethostname
- X * didn't get that for us.
- X *
- X * Then look in users' .rhosts and try those strings (maybe)
- X */
- X return(PWCK_OK);
- X}
- X/* End pwck_local.c */
- END_OF_FILE
- if test 1637 -ne `wc -c <'checkpasswd/pwck_local.c'`; then
- echo shar: \"'checkpasswd/pwck_local.c'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/pwck_local.c'
- fi
- if test -f 'checkpasswd/pwck_passwd.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/pwck_passwd.c'\"
- else
- echo shar: Extracting \"'checkpasswd/pwck_passwd.c'\" \(3284 characters\)
- sed "s/^X//" >'checkpasswd/pwck_passwd.c' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * pwck_password - Check password candidate against the users' password
- X * file information, or any other information that is publicly
- X * available about this user that a bandit could use as
- X * password guesses.
- X *
- X * This code has an option for the User Information Data Base used
- X * at the UT Computation Center. Here is the place to search
- X * any local 'finger' database.
- X */
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)pwck_passwd.c 1.2 6/5/89 (cc.utexas.edu)";
- X#endif
- X
- X#include "checkpasswd.h"
- X
- X#ifdef UTEXAS_CC
- X/*
- X * For UTCC systems
- X */
- X#include <local/userinfo.h>
- X#define cname pwp->ui_name
- Xtypedef userptr pwptr;
- X#define setpwent setuserent
- X#define getpwuid getuserbyuid
- X
- X#else /* UTEXAS_CC */
- X
- X#include <pwd.h>
- X#define cname pwp->pw_name
- Xtypedef struct passwd *pwptr;
- X
- X#endif /* UTEXAS_CC */
- X
- Xpwck_passwd(password, userid, mesg)
- Xchar *password;
- Xint userid;
- Xchar *mesg;
- X{
- X char temp[BUFSIZ]; /* Scratch */
- X pwptr pwp; /* Pointer to user information */
- X
- X mesg[0] = 0;
- X#ifdef DEBUG
- X printf("pwck_passwd: \"%s\"\n", password);
- X#endif
- X if (userid < 0) /* Can't do user checks */
- X return(PWCK_FAIL);
- X
- X pwp = getpwuid(userid);
- X if (pwp == (pwptr )0)
- X return(PWCK_FAIL);
- X
- X strcpy(mesg, "Password is part of your passwd information");
- X try(password, cname, PWCK_OBVIOUS); /* Checks 'name' and 'Name' */
- X
- X (void) strcpy(temp, cname);
- X (void) strcat(temp, cname);
- X try(password, temp, PWCK_OBVIOUS); /* Check 'namename' */
- X
- X (void) strcpy(temp, cname);
- X _flipstring(temp);
- X try(password, temp, PWCK_OBVIOUS); /* 'eman' */
- X
- X#ifdef UTEXAS_CC
- X /*
- X * Try the rest of the stuff in this userinfo record
- X */
- X try(password, pwp->ui_rje_cc, PWCK_OBVIOUS);
- X try(password, pwp->ui_bill_cc, PWCK_OBVIOUS);
- X
- X mesg[0] = 0;
- X /* Try all 'finger' information */
- X mtry(password, pwp->ui_personal_name, PWCK_FINGER);
- X mtry(password, pwp->ui_nick_name, PWCK_FINGER);
- X mtry(password, pwp->ui_home_address, PWCK_FINGER);
- X mtry(password, pwp->ui_work_address, PWCK_FINGER);
- X mtry(password, pwp->ui_home_phone, PWCK_FINGER);
- X mtry(password, pwp->ui_work_phone, PWCK_FINGER);
- X mtry(password, pwp->ui_birthday, PWCK_FINGER);
- X mtry(password, pwp->ui_project, PWCK_FINGER);
- X mtry(password, pwp->ui_fellows, PWCK_FINGER);
- X#else
- X /*
- X * Try every word in user's GECOS entry
- X */
- X mesg[0] = 0;
- X mtry(password, pwp->pw_gecos, PWCK_FINGER);
- X#endif
- X return(PWCK_OK);
- X}
- X/* End pwck_passwd.c */
- END_OF_FILE
- if test 3284 -ne `wc -c <'checkpasswd/pwck_passwd.c'`; then
- echo shar: \"'checkpasswd/pwck_passwd.c'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/pwck_passwd.c'
- fi
- if test -f 'checkpasswd/version.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'checkpasswd/version.h'\"
- else
- echo shar: Extracting \"'checkpasswd/version.h'\" \(1084 characters\)
- sed "s/^X//" >'checkpasswd/version.h' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * checkpasswd version information
- X * @(#)version.h 1.1 5/18/89
- X */
- Xchar *version = "checkpasswd 1.1 (5/12/89)\n",
- X *patchlevel = "2 (5/12/89)\n";
- X
- X/* End version.h */
- END_OF_FILE
- if test 1084 -ne `wc -c <'checkpasswd/version.h'`; then
- echo shar: \"'checkpasswd/version.h'\" unpacked with wrong size!
- fi
- # end of 'checkpasswd/version.h'
- fi
- if test -f 'npasswd.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'npasswd.1'\"
- else
- echo shar: Extracting \"'npasswd.1'\" \(1764 characters\)
- sed "s/^X//" >'npasswd.1' <<'END_OF_FILE'
- X'\"
- X'\" @(#)npasswd.1 1.3 8/14/90 (cc.utexas.edu)
- X'\"
- X.TH NPASSWD 1
- X.SH NAME
- Xnpasswd \- change login password
- X.SH SYNOPSIS
- X.B npasswd
- X[
- X.B \-\^P
- X] [
- X.B \-\^V
- X] [ username ]
- X.SH DESCRIPTION
- X.I Npasswd
- Xchanges or installs a login password for
- X.B username
- X(your own by default).
- XOnly the super-user can change another users' password.
- X.PP
- XWhen changing a password,
- X.I npasswd
- Xprompts for the old password and then for the new one.
- XThe new password must be typed twice to forestall mistakes.
- XThe new password is checked for reasonableness.
- X.PP
- X.I Npasswd
- Xaccepts the option switches of the 4.3BSD and SunOS 4.X
- X.I passwd
- Xbut impliments none of them.
- XThe
- X.B \-\^V
- Xoption prints version and patch level information.
- X.PP
- XThe
- X.B \-\^P
- Xoption indicates that
- X.B npasswd
- Xwill be fed input from another program via a pipe.
- XThis option is reserved for the super-user.
- X.PP
- X.I Npasswd
- Xcan change both local passwords and passwords in a
- XNetwork Information Service (aka Yellow Pages) database.
- X.SH "THIS IS NOT A REAL MANUAL PAGE"
- X\fB
- XIt will probably be easier to adapt the manual page for
- Xthe existing version of passwd installed.
- XI have put much of the particulars about configuring npasswd into the help file.
- X\fR
- X.br
- X.SH "SEE ALSO"
- Xpasswd(1), passwd(5), yppasswd(3R), yppasswdd(8C),
- Xfinger(1), login(1), crypt(3), passwd.adjuct(5), ypfiles(5), ypmake(8)
- X.SH DIAGNOSTICS
- XVarious, hopefully self-explanitory.
- X.SH BUGS
- XThis program could do shells and fullnames.
- XProbably a future version will.
- XSince it tries to work for a range of UNIX systems, it will without
- Xdoubt not do everything quite as well as the vendor-supplied version.
- X.SH AUTHOR
- XClyde Hoover
- X.br
- XComputation Center
- X.br
- XThe University of Texas at Austin
- X.br
- Xclyde@emx.utexas.edu, uunet!cs.utexas.edu!ut-emx!clyde
- END_OF_FILE
- if test 1764 -ne `wc -c <'npasswd.1'`; then
- echo shar: \"'npasswd.1'\" unpacked with wrong size!
- fi
- # end of 'npasswd.1'
- fi
- if test -f 'npasswd.conf' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'npasswd.conf'\"
- else
- echo shar: Extracting \"'npasswd.conf'\" \(551 characters\)
- sed "s/^X//" >'npasswd.conf' <<'END_OF_FILE'
- X#
- X# npasswd configuration file
- X#
- X# dictionary - Specify dictionary to look in.
- X# There may be multiple such entries.
- X# dictionary /path/to/dictionary [description]
- X
- X# singlecase yes | [no] - Pass single-case passwords
- X# singlecase yes
- X
- X# minlength N [5] - Minimum password length
- X# minlength 6
- X
- X# maxlength N [8] Maximum effective password length
- X# (for warning purposes only)
- X
- X# printonly yes | [no] - Allow only printable characters
- X
- X# badchars "<string>" - Replace illegal character list
- X# badchars +"<string>" - Add to illegal character list
- END_OF_FILE
- if test 551 -ne `wc -c <'npasswd.conf'`; then
- echo shar: \"'npasswd.conf'\" unpacked with wrong size!
- fi
- # end of 'npasswd.conf'
- fi
- if test -f 'npasswd.help' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'npasswd.help'\"
- else
- echo shar: Extracting \"'npasswd.help'\" \(695 characters\)
- sed "s/^X//" >'npasswd.help' <<'END_OF_FILE'
- X
- XPasswd help file, version 1.1 of 9/21/89
- X
- XA UNIX system password should be at least 6 characters long and include
- Xat least one upper case letter (A-Z), digit (0-9) or punctuation character
- X(such as . , or - ).
- X
- XPasswords will NOT be accepted that:
- X
- X * Are less than 6 characters long.
- X
- X * Matches anything in your UNIX account information, such as your login
- X name or an item from your "finger" data entry.
- X
- X * Are found in the system's spelling dictionary - unless it has some
- X uppercase letters other than the first character.
- X For example, "Explain" would be rejected but "exPlain" would
- X be accepted.
- X
- X * Have more than 3 repeated characters - thus "aaa" would be rejected.
- END_OF_FILE
- if test 695 -ne `wc -c <'npasswd.help'`; then
- echo shar: \"'npasswd.help'\" unpacked with wrong size!
- fi
- # end of 'npasswd.help'
- fi
- if test -f 'npasswd.motd' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'npasswd.motd'\"
- else
- echo shar: Extracting \"'npasswd.motd'\" \(43 characters\)
- sed "s/^X//" >'npasswd.motd' <<'END_OF_FILE'
- XA local message can be put into this file.
- END_OF_FILE
- if test 43 -ne `wc -c <'npasswd.motd'`; then
- echo shar: \"'npasswd.motd'\" unpacked with wrong size!
- fi
- # end of 'npasswd.motd'
- fi
- if test -f 'npasswd.shar' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'npasswd.shar'\"
- else
- echo shar: Extracting \"'npasswd.shar'\" \(1242 characters\)
- sed "s/^X//" >'npasswd.shar' <<'END_OF_FILE'
- X File Name Archive # Description
- X-----------------------------------------------------------
- X CHANGE.LOG 3
- X MANIFEST 1
- X Makefile.dist 2
- X README 1
- X checkpasswd/Makefile 1
- X checkpasswd/README 2
- X checkpasswd/call_ckpasswd.c 1
- X checkpasswd/checkpasswd.3 1
- X checkpasswd/checkpasswd.8 2
- X checkpasswd/checkpasswd.c 1
- X checkpasswd/checkpasswd.cf 1
- X checkpasswd/checkpasswd.h 1
- X checkpasswd/dict/Makefile 1
- X checkpasswd/dict/README 1
- X checkpasswd/dict/makedict.8 1
- X checkpasswd/dict/makedict.c 1
- X checkpasswd/dict/viewdict.8 1
- X checkpasswd/dict/viewdict.c 1
- X checkpasswd/libmain.c 1
- X checkpasswd/main.c 1
- X checkpasswd/pwck_dict.c 2
- X checkpasswd/pwck_lexical.c 2
- X checkpasswd/pwck_local.c 1
- X checkpasswd/pwck_passwd.c 1
- X checkpasswd/util.c 3
- X checkpasswd/version.h 1
- X npasswd.1 1
- X npasswd.c 3
- X npasswd.conf 1
- X npasswd.help 1
- X npasswd.motd 1
- X npasswd.shar 1 This shipping list
- X pw_passwd.c 2
- X pw_userinfo.c 2
- X pw_yp.c 3
- X version.h 1
- END_OF_FILE
- if test 1242 -ne `wc -c <'npasswd.shar'`; then
- echo shar: \"'npasswd.shar'\" unpacked with wrong size!
- fi
- # end of 'npasswd.shar'
- fi
- if test -f 'version.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'version.h'\"
- else
- echo shar: Extracting \"'version.h'\" \(1076 characters\)
- sed "s/^X//" >'version.h' <<'END_OF_FILE'
- X
- X/* -------------------------------------------------------------------- */
- X/* */
- X/* Author: Clyde Hoover */
- X/* Computation Center */
- X/* The University of Texas at Austin */
- X/* Austin, Texas 78712 */
- X/* clyde@emx.utexas.edu */
- X/* uunet!cs.utexas.edu!ut-emx!clyde */
- X/* */
- X/*This code may be distributed freely, provided this notice is retained. */
- X/* */
- X/* -------------------------------------------------------------------- */
- X/*
- X * npasswd version information
- X * @(#)version.h 1.6 version.h
- X */
- Xchar *version = "npasswd 1.2 (03/19/90)",
- X *patchlevel = "2 (01/24/91)";
- X
- X/* End version.h */
- END_OF_FILE
- if test 1076 -ne `wc -c <'version.h'`; then
- echo shar: \"'version.h'\" unpacked with wrong size!
- fi
- # end of 'version.h'
- fi
- echo shar: End of archive 1 \(of 3\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Clyde Hoover (Shouter-To-Dead-Parrots) |
- UNIX/VMS Services | "Any sufficently advanced technology
- Compuatation Center, UT Austin | is indisguishable from a rigged demo."
- clyde@emx.utexas.edu |
-
-